if (FFMPEG_FOUND OR MPG123_FOUND)
    include_directories(${QTINCLUDES} ${ZLIB_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
    if (FFMPEG_FOUND)
        set(CANTATA_RG_SRCS ${CANTATA_RG_SRCS} ffmpeginput.cpp)
        include_directories(${FFMPEG_INCLUDE_DIRS})
    endif ()
    if (MPG123_FOUND)
        set(CANTATA_RG_SRCS ${CANTATA_RG_SRCS} mpg123input.cpp)
        include_directories(${MPG123_INCLUDE_DIRS})
    endif ()

    set(CANTATA_RG_SRCS ${CANTATA_RG_SRCS} main.cpp replaygain.cpp trackscanner.cpp jobcontroller.cpp ../support/thread.cpp)

    if (WIN32)
        set(CMAKE_BUILD_TYPE "Release")
        ADD_EXECUTABLE(cantata-replaygain WIN32 ${CANTATA_RG_SRCS} ${CANTATA_PO})
        install(TARGETS cantata-replaygain DESTINATION ${CMAKE_INSTALL_PREFIX})
    elseif (APPLE)
        set(CMAKE_BUILD_TYPE "Release")
        ADD_EXECUTABLE(cantata-replaygain ${CANTATA_RG_SRCS} ${CANTATA_PO})
#        install(TARGETS cantata-replaygain DESTINATION ${MACOSX_BUNDLE_APP_DIR})
    else ()
        ADD_EXECUTABLE(cantata-replaygain ${CANTATA_RG_SRCS})
        install(TARGETS cantata-replaygain RUNTIME DESTINATION ${LINUX_LIB_DIR}/cantata)
    endif ()

    find_package(Ebur128)

    if (EBUR128_FOUND)
        message("-- Using system libebur128")
        include_directories(${EBUR128_INCLUDE_DIR})
        target_link_libraries(cantata-replaygain ${EBUR128_LIBRARY})
    else ()
        message("-- Using supplied libebur128")
        include_directories(${CMAKE_SOURCE_DIR}/3rdparty)
        add_subdirectory(${CMAKE_SOURCE_DIR}/3rdparty/ebur128 ${CMAKE_BINARY_DIR}/3rdparty/ebur128)
        target_link_libraries(cantata-replaygain ebur128)
    endif ()

    if (FFMPEG_FOUND)
        target_link_libraries(cantata-replaygain ${FFMPEG_LIBRARIES})
    endif ()
    if (MPG123_FOUND)
        target_link_libraries(cantata-replaygain ${MPG123_LIBRARIES})
    endif ()
    target_link_libraries(cantata-replaygain ${QTCORELIBS})
    if (UNIX AND NOT APPLE)
        target_link_libraries(cantata-replaygain -lpthread)
    endif ()
endif ()

